package cz.muni.fi.pa165.sme.client.converters;

import cz.muni.fi.pa165.sme.client.fo.BurnedCaloriesFO;
import cz.muni.fi.pa165.sportmanager.burnedcaloriesws.BurnedCalories;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;

/**
 * @author jirankova
 */
public class BurnedCalories2BurnedCaloriesFOConverter implements Converter<BurnedCalories, BurnedCaloriesFO> {

	@Autowired
	private SportActivity2SportActivityFOConverter converter;

	@Override
	public BurnedCaloriesFO convert(final BurnedCalories source) {
		if (source == null) {
			return null;
		}

		final BurnedCaloriesFO target = new BurnedCaloriesFO();

		target.setCalories(Long.valueOf(source.getCalories()));
		target.setId(Long.valueOf(source.getId()));
		target.setSpeed(Float.valueOf(source.getSpeed()));
		target.setSportActivity(converter.convert(source.getSportActivity()));
		target.setWeight(Float.valueOf(source.getWeight()));

		return target;
	}
}
